USE [master]
GO

/****** Object:  Database [SmartHealthCare]    Script Date: 06/19/2010 22:13:10 ******/
CREATE DATABASE [SmartHealthCare] ON  PRIMARY 
( NAME = N'SmartHealthCare', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\SmartHealthCare.mdf' , SIZE = 2048KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
 LOG ON 
( NAME = N'SmartHealthCare_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\SmartHealthCare_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO

ALTER DATABASE [SmartHealthCare] SET COMPATIBILITY_LEVEL = 100
GO

IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [SmartHealthCare].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO

ALTER DATABASE [SmartHealthCare] SET ANSI_NULL_DEFAULT OFF 
GO

ALTER DATABASE [SmartHealthCare] SET ANSI_NULLS OFF 
GO

ALTER DATABASE [SmartHealthCare] SET ANSI_PADDING OFF 
GO

ALTER DATABASE [SmartHealthCare] SET ANSI_WARNINGS OFF 
GO

ALTER DATABASE [SmartHealthCare] SET ARITHABORT OFF 
GO

ALTER DATABASE [SmartHealthCare] SET AUTO_CLOSE OFF 
GO

ALTER DATABASE [SmartHealthCare] SET AUTO_CREATE_STATISTICS ON 
GO

ALTER DATABASE [SmartHealthCare] SET AUTO_SHRINK OFF 
GO

ALTER DATABASE [SmartHealthCare] SET AUTO_UPDATE_STATISTICS ON 
GO

ALTER DATABASE [SmartHealthCare] SET CURSOR_CLOSE_ON_COMMIT OFF 
GO

ALTER DATABASE [SmartHealthCare] SET CURSOR_DEFAULT  GLOBAL 
GO

ALTER DATABASE [SmartHealthCare] SET CONCAT_NULL_YIELDS_NULL OFF 
GO

ALTER DATABASE [SmartHealthCare] SET NUMERIC_ROUNDABORT OFF 
GO

ALTER DATABASE [SmartHealthCare] SET QUOTED_IDENTIFIER OFF 
GO

ALTER DATABASE [SmartHealthCare] SET RECURSIVE_TRIGGERS OFF 
GO

ALTER DATABASE [SmartHealthCare] SET  DISABLE_BROKER 
GO

ALTER DATABASE [SmartHealthCare] SET AUTO_UPDATE_STATISTICS_ASYNC OFF 
GO

ALTER DATABASE [SmartHealthCare] SET DATE_CORRELATION_OPTIMIZATION OFF 
GO

ALTER DATABASE [SmartHealthCare] SET TRUSTWORTHY OFF 
GO

ALTER DATABASE [SmartHealthCare] SET ALLOW_SNAPSHOT_ISOLATION OFF 
GO

ALTER DATABASE [SmartHealthCare] SET PARAMETERIZATION SIMPLE 
GO

ALTER DATABASE [SmartHealthCare] SET READ_COMMITTED_SNAPSHOT OFF 
GO

ALTER DATABASE [SmartHealthCare] SET HONOR_BROKER_PRIORITY OFF 
GO

ALTER DATABASE [SmartHealthCare] SET  READ_WRITE 
GO

ALTER DATABASE [SmartHealthCare] SET RECOVERY FULL 
GO

ALTER DATABASE [SmartHealthCare] SET  MULTI_USER 
GO

ALTER DATABASE [SmartHealthCare] SET PAGE_VERIFY CHECKSUM  
GO

ALTER DATABASE [SmartHealthCare] SET DB_CHAINING OFF 
GO


USE [SmartHealthCare]
GO
/****** Object:  Table [dbo].[ClaseInsumo]    Script Date: 06/19/2010 22:12:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[ClaseInsumo](
	[IdClaseInsumo] [int] IDENTITY(1,1) NOT NULL,
	[Descripcion] [varchar](256) NULL,
 CONSTRAINT [PK_ClaseInsumo] PRIMARY KEY CLUSTERED 
(
	[IdClaseInsumo] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Aseguradoras]    Script Date: 06/19/2010 22:12:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Aseguradoras](
	[IdAseguradora] [int] IDENTITY(1,1) NOT NULL,
	[CodigoAseguradora]  AS (right('A00000000'+CONVERT([varchar](15),[IdAseguradora],0),(15))),
	[Nombre] [varchar](256) NULL,
 CONSTRAINT [PK_Aseguradoras] PRIMARY KEY CLUSTERED 
(
	[IdAseguradora] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[EstadoConsulta]    Script Date: 06/19/2010 22:12:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[EstadoConsulta](
	[IdEstado] [int] IDENTITY(1,1) NOT NULL,
	[Decripcion] [varchar](256) NULL,
 CONSTRAINT [PK_EstadoConsulta] PRIMARY KEY CLUSTERED 
(
	[IdEstado] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[EspecialidadesMedicas]    Script Date: 06/19/2010 22:12:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[EspecialidadesMedicas](
	[IdEspecialidad] [int] IDENTITY(1,1) NOT NULL,
	[Descripcion] [varchar](256) NULL,
 CONSTRAINT [PK_EspecialidadesMedicas] PRIMARY KEY CLUSTERED 
(
	[IdEspecialidad] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[TipoIdentificacion]    Script Date: 06/19/2010 22:12:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[TipoIdentificacion](
	[IdTipoIdentificacion] [int] NOT NULL,
	[Descripcion] [varchar](256) NULL,
 CONSTRAINT [PK_TipoIdentificacion] PRIMARY KEY CLUSTERED 
(
	[IdTipoIdentificacion] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[IndicacionesDeUso]    Script Date: 06/19/2010 22:12:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[IndicacionesDeUso](
	[IdIndicacionesdeUso] [int] IDENTITY(1,1) NOT NULL,
	[Descripcion] [varchar](256) NULL,
 CONSTRAINT [PK_IndicacionesDeUso] PRIMARY KEY CLUSTERED 
(
	[IdIndicacionesdeUso] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Unidades]    Script Date: 06/19/2010 22:12:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Unidades](
	[IdUnidades] [int] IDENTITY(1,1) NOT NULL,
	[Descripcion] [varchar](100) NULL,
 CONSTRAINT [PK_Unidades] PRIMARY KEY CLUSTERED 
(
	[IdUnidades] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[TiposViasDeContacto]    Script Date: 06/19/2010 22:12:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[TiposViasDeContacto](
	[IdTipoVia] [int] IDENTITY(1,1) NOT NULL,
	[Descripcion] [varchar](256) NULL,
 CONSTRAINT [PK_TiposViasDeContacto] PRIMARY KEY CLUSTERED 
(
	[IdTipoVia] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[TiposSeguro]    Script Date: 06/19/2010 22:12:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[TiposSeguro](
	[IdTipoSeguro] [int] IDENTITY(1,1) NOT NULL,
	[Descripcion] [varchar](256) NULL,
 CONSTRAINT [PK_TiposSeguro] PRIMARY KEY CLUSTERED 
(
	[IdTipoSeguro] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[TiposDeServicio]    Script Date: 06/19/2010 22:12:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[TiposDeServicio](
	[IdTipoDeServicio] [int] IDENTITY(1,1) NOT NULL,
	[Descripcion] [varchar](256) NULL,
 CONSTRAINT [PK_TiposDeServicio] PRIMARY KEY CLUSTERED 
(
	[IdTipoDeServicio] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Parentescos]    Script Date: 06/19/2010 22:12:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Parentescos](
	[IdParentesco] [int] IDENTITY(1,1) NOT NULL,
	[Descripcion] [varchar](256) NULL,
 CONSTRAINT [PK_Parentescos] PRIMARY KEY CLUSTERED 
(
	[IdParentesco] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[TiposCliente]    Script Date: 06/19/2010 22:12:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[TiposCliente](
	[IdTipoCliente] [int] IDENTITY(1,1) NOT NULL,
	[Descripcion] [varchar](256) NULL,
 CONSTRAINT [PK_TiposCliente] PRIMARY KEY CLUSTERED 
(
	[IdTipoCliente] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[TipoInsumo]    Script Date: 06/19/2010 22:12:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[TipoInsumo](
	[IdTipoInsumo] [int] IDENTITY(1,1) NOT NULL,
	[ClaseInsumo] [int] NULL,
	[Descricion] [varchar](256) NULL,
 CONSTRAINT [PK_TipoInsumo] PRIMARY KEY CLUSTERED 
(
	[IdTipoInsumo] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[TiposDeSeguroPorAseguradora]    Script Date: 06/19/2010 22:12:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TiposDeSeguroPorAseguradora](
	[IdTiposSegurosPorAseguradora] [int] IDENTITY(1,1) NOT NULL,
	[IdAseguradora] [int] NULL,
	[IdTipoSeguro] [int] NULL,
 CONSTRAINT [PK_TiposDeSeguroPorAseguradora] PRIMARY KEY CLUSTERED 
(
	[IdTiposSegurosPorAseguradora] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[CoberturaPorTipoSeguroMedico]    Script Date: 06/19/2010 22:12:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[CoberturaPorTipoSeguroMedico](
	[IdCobertura] [int] IDENTITY(1,1) NOT NULL,
	[IdTIpoSeguro] [int] NULL,
	[CampoId] [varchar](50) NULL,
	[Porcentaje] [numeric](10, 2) NULL,
 CONSTRAINT [PK_CoberturaPorTipoSeguroMedico] PRIMARY KEY CLUSTERED 
(
	[IdCobertura] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Clientes]    Script Date: 06/19/2010 22:12:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Clientes](
	[IdCliente] [int] IDENTITY(1,1) NOT NULL,
	[CodigoCliente]  AS (right('C00000000'+CONVERT([varchar](15),[IdCliente],(0)),(15))),
	[TipoCliente] [int] NULL,
	[Nombre] [varchar](256) NULL,
	[Genero] [varchar](2) NULL,
	[Identificacion] [int] NULL,
	[FechaNacimiento] [datetime] NULL,
	[CodigoSeguro] [varchar](100) NULL,
	[NSS] [varchar](50) NULL,
	[CodigoAseguradora] [int] NULL,
	[TipoSeguro] [int] NULL,
 CONSTRAINT [PK_Clientes] PRIMARY KEY CLUSTERED 
(
	[IdCliente] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Medicos]    Script Date: 06/19/2010 22:12:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Medicos](
	[IdMedico] [int] IDENTITY(1,1) NOT NULL,
	[CodigoMedico]  AS (right('M00000000'+CONVERT([varchar](15),[IdMedico],0),(15))),
	[Nombre] [varchar](256) NULL,
	[IdEspecialidad] [int] NULL,
	[FechaEntrada] [datetime] NULL,
	[Activo] [bit] NULL,
 CONSTRAINT [PK_Medicos] PRIMARY KEY CLUSTERED 
(
	[IdMedico] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[ServiciosMedicos]    Script Date: 06/19/2010 22:12:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[ServiciosMedicos](
	[IdServicioMedico] [int] IDENTITY(1,1) NOT NULL,
	[CodigoServicio]  AS (right('S00000000'+CONVERT([varchar](15),[IdServicioMedico],0),(15))),
	[TipoDeServicio] [int] NULL,
	[TipoUnidad] [int] NULL,
	[Descripcion] [varchar](256) NULL,
 CONSTRAINT [PK_ServiciosMedicos] PRIMARY KEY CLUSTERED 
(
	[IdServicioMedico] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[PersonasDeContacto]    Script Date: 06/19/2010 22:12:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[PersonasDeContacto](
	[IdContacto] [int] IDENTITY(1,1) NOT NULL,
	[IdCliente] [int] NULL,
	[Nombre] [varchar](256) NULL,
	[Parentesco] [int] NULL,
 CONSTRAINT [PK_PersonasDeContacto] PRIMARY KEY CLUSTERED 
(
	[IdContacto] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[MaterialGastableServiciosMedicos]    Script Date: 06/19/2010 22:12:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[MaterialGastableServiciosMedicos](
	[IdMaterialGastableServicioMedico] [int] IDENTITY(1,1) NOT NULL,
	[IdInsumo] [int] NULL,
	[IdServicioMedico] [int] NULL,
	[Cantidad] [numeric](10, 2) NULL,
 CONSTRAINT [PK_MaterialGastableServiciosMedicos] PRIMARY KEY CLUSTERED 
(
	[IdMaterialGastableServicioMedico] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Insumos]    Script Date: 06/19/2010 22:12:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Insumos](
	[IdInsumo] [int] IDENTITY(1,1) NOT NULL,
	[Codigo]  AS (right('I00000000'+CONVERT([varchar](15),[IdInsumo],0),(15))),
	[TipoInsumo] [int] NULL,
	[ClaseInsumo] [int] NULL,
	[Descripcion] [varchar](256) NULL,
	[TipoUnidad] [int] NULL,
 CONSTRAINT [PK_Insumos] PRIMARY KEY CLUSTERED 
(
	[IdInsumo] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[HistorialClinico]    Script Date: 06/19/2010 22:12:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[HistorialClinico](
	[IdHistorial] [int] IDENTITY(1,1) NOT NULL,
	[IdPaciente] [int] NOT NULL,
	[Codigo]  AS (right('H00000000'+CONVERT([varchar](15),[IdHistorial],(0)),(15))),
	[FechaEntrada] [datetime] NULL,
	[Estado] [bit] NULL,
 CONSTRAINT [PK_HistorialClinico] PRIMARY KEY CLUSTERED 
(
	[IdHistorial] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[ServiciosPorCobertura]    Script Date: 06/19/2010 22:12:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ServiciosPorCobertura](
	[IdServicioPorCobertura] [int] IDENTITY(1,1) NOT NULL,
	[IdServicio] [int] NULL,
	[IdCovertura] [int] NULL,
 CONSTRAINT [PK_ServiciosPorCobertura] PRIMARY KEY CLUSTERED 
(
	[IdServicioPorCobertura] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[ServiciosMedicosPorMedicos]    Script Date: 06/19/2010 22:12:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ServiciosMedicosPorMedicos](
	[IdServiciosMedicosPorMedicos] [int] IDENTITY(1,1) NOT NULL,
	[IdMedico] [int] NULL,
	[IdServicioMedico] [int] NULL,
 CONSTRAINT [PK_ServiciosMedicosPorMedicos] PRIMARY KEY CLUSTERED 
(
	[IdServiciosMedicosPorMedicos] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[ConsultaMedica]    Script Date: 06/19/2010 22:12:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ConsultaMedica](
	[IdConsulta] [int] IDENTITY(1,1) NOT NULL,
	[IdMedico] [int] NULL,
	[IdPaciente] [int] NULL,
	[FechaCita] [nchar](10) NULL,
	[Estado] [int] NULL,
 CONSTRAINT [PK_ConsultaMedica] PRIMARY KEY CLUSTERED 
(
	[IdConsulta] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[PacientesPorMedicos]    Script Date: 06/19/2010 22:12:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[PacientesPorMedicos](
	[IdPacientesPorMedicos] [int] IDENTITY(1,1) NOT NULL,
	[IdMedico] [int] NULL,
	[IdPaciente] [int] NULL,
 CONSTRAINT [PK_PacientesPorMedicos] PRIMARY KEY CLUSTERED 
(
	[IdPacientesPorMedicos] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[ViasDeContactoClientes]    Script Date: 06/19/2010 22:12:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[ViasDeContactoClientes](
	[IdViaContacto] [int] IDENTITY(1,1) NOT NULL,
	[IdCliente] [int] NULL,
	[TipoVia] [int] NULL,
	[Descripcion] [varchar](256) NULL,
 CONSTRAINT [PK_ViasDeContactoClientes] PRIMARY KEY CLUSTERED 
(
	[IdViaContacto] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[ViasDeContacto]    Script Date: 06/19/2010 22:12:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[ViasDeContacto](
	[IdViaContacto] [int] IDENTITY(1,1) NOT NULL,
	[IdPersona] [int] NULL,
	[TipoVia] [int] NULL,
	[Descripcion] [varchar](256) NULL,
 CONSTRAINT [PK_ViasDeContacto] PRIMARY KEY CLUSTERED 
(
	[IdViaContacto] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[ServiciosMedicosMedicamentos]    Script Date: 06/19/2010 22:12:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ServiciosMedicosMedicamentos](
	[IdServicioMedicoMedicamento] [int] IDENTITY(1,1) NOT NULL,
	[IdServicioMedico] [int] NULL,
	[IdInsumo] [int] NULL,
	[Cantidad] [numeric](10, 2) NULL,
 CONSTRAINT [PK_ServiciosMedicosMedicamentos] PRIMARY KEY CLUSTERED 
(
	[IdServicioMedicoMedicamento] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[HistorialClinicoDetalle]    Script Date: 06/19/2010 22:12:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[HistorialClinicoDetalle](
	[IdHistorial] [int] NOT NULL,
	[Secuencia] [int] NOT NULL,
	[IdMedico] [int] NULL,
	[IdServicioMedico] [int] NULL,
	[Fecha] [datetime] NULL,
	[Nota] [text] NULL,
 CONSTRAINT [PK_HistorialClinicoDetalle] PRIMARY KEY CLUSTERED 
(
	[IdHistorial] ASC,
	[Secuencia] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
/****** Object:  Table [dbo].[IndicacionesDeUsoInsumos]    Script Date: 06/19/2010 22:12:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[IndicacionesDeUsoInsumos](
	[IdIndicaciotnesDeUsoInsumo] [int] IDENTITY(1,1) NOT NULL,
	[IdIndicacionInsumo] [int] NOT NULL,
	[IdInsumo] [int] NULL,
 CONSTRAINT [PK_IndicacionesDeUsoInsumos] PRIMARY KEY CLUSTERED 
(
	[IdIndicaciotnesDeUsoInsumo] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[ContactosClientes]    Script Date: 06/19/2010 22:12:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ContactosClientes](
	[IdContacto] [int] IDENTITY(1,1) NOT NULL,
	[IdCliente] [int] NULL,
	[IdViaContacto] [int] NULL,
 CONSTRAINT [PK_ContactosClientes] PRIMARY KEY CLUSTERED 
(
	[IdContacto] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Contactos]    Script Date: 06/19/2010 22:12:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Contactos](
	[IdContacto] [int] IDENTITY(1,1) NOT NULL,
	[IdPersonaContacto] [int] NULL,
	[IdViaContacto] [int] NULL,
 CONSTRAINT [PK_Contactos] PRIMARY KEY CLUSTERED 
(
	[IdContacto] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Default [DF_TipoInsumo_ClaseInsumo]    Script Date: 06/19/2010 22:12:29 ******/
ALTER TABLE [dbo].[TipoInsumo] ADD  CONSTRAINT [DF_TipoInsumo_ClaseInsumo]  DEFAULT ((1)) FOR [ClaseInsumo]
GO
/****** Object:  Default [DF_Clientes_TipoCLiente]    Script Date: 06/19/2010 22:12:29 ******/
ALTER TABLE [dbo].[Clientes] ADD  CONSTRAINT [DF_Clientes_TipoCLiente]  DEFAULT ((1)) FOR [TipoCliente]
GO
/****** Object:  Default [DF_Clientes_CodigoAseguradora]    Script Date: 06/19/2010 22:12:29 ******/
ALTER TABLE [dbo].[Clientes] ADD  CONSTRAINT [DF_Clientes_CodigoAseguradora]  DEFAULT ((1)) FOR [CodigoAseguradora]
GO
/****** Object:  Default [DF_Clientes_TipoSeguro]    Script Date: 06/19/2010 22:12:29 ******/
ALTER TABLE [dbo].[Clientes] ADD  CONSTRAINT [DF_Clientes_TipoSeguro]  DEFAULT ((1)) FOR [TipoSeguro]
GO
/****** Object:  Default [DF_PersonasDeContacto_Parentesco]    Script Date: 06/19/2010 22:12:29 ******/
ALTER TABLE [dbo].[PersonasDeContacto] ADD  CONSTRAINT [DF_PersonasDeContacto_Parentesco]  DEFAULT ((1)) FOR [Parentesco]
GO
/****** Object:  Default [DF_MaterialGastableServiciosMedicos_Cantidad]    Script Date: 06/19/2010 22:12:29 ******/
ALTER TABLE [dbo].[MaterialGastableServiciosMedicos] ADD  CONSTRAINT [DF_MaterialGastableServiciosMedicos_Cantidad]  DEFAULT ((0.0)) FOR [Cantidad]
GO
/****** Object:  Default [DF_Insumos_TipoInsumo]    Script Date: 06/19/2010 22:12:29 ******/
ALTER TABLE [dbo].[Insumos] ADD  CONSTRAINT [DF_Insumos_TipoInsumo]  DEFAULT ((1)) FOR [TipoInsumo]
GO
/****** Object:  Default [DF_Insumos_ClaseInsumo]    Script Date: 06/19/2010 22:12:29 ******/
ALTER TABLE [dbo].[Insumos] ADD  CONSTRAINT [DF_Insumos_ClaseInsumo]  DEFAULT ((1)) FOR [ClaseInsumo]
GO
/****** Object:  Default [DF_Insumos_TipoUnidad]    Script Date: 06/19/2010 22:12:29 ******/
ALTER TABLE [dbo].[Insumos] ADD  CONSTRAINT [DF_Insumos_TipoUnidad]  DEFAULT ((1)) FOR [TipoUnidad]
GO
/****** Object:  Default [DF_ViasDeContacto_TipoVia]    Script Date: 06/19/2010 22:12:30 ******/
ALTER TABLE [dbo].[ViasDeContacto] ADD  CONSTRAINT [DF_ViasDeContacto_TipoVia]  DEFAULT ((1)) FOR [TipoVia]
GO
/****** Object:  Default [DF_ServiciosMedicosMedicamentos_Cantidad]    Script Date: 06/19/2010 22:12:30 ******/
ALTER TABLE [dbo].[ServiciosMedicosMedicamentos] ADD  CONSTRAINT [DF_ServiciosMedicosMedicamentos_Cantidad]  DEFAULT ((0.0)) FOR [Cantidad]
GO
/****** Object:  ForeignKey [FK_TipoInsumo_ClaseInsumo]    Script Date: 06/19/2010 22:12:29 ******/
ALTER TABLE [dbo].[TipoInsumo]  WITH CHECK ADD  CONSTRAINT [FK_TipoInsumo_ClaseInsumo] FOREIGN KEY([ClaseInsumo])
REFERENCES [dbo].[ClaseInsumo] ([IdClaseInsumo])
GO
ALTER TABLE [dbo].[TipoInsumo] CHECK CONSTRAINT [FK_TipoInsumo_ClaseInsumo]
GO
/****** Object:  ForeignKey [FK_TiposDeSeguroPorAseguradora_Aseguradoras]    Script Date: 06/19/2010 22:12:29 ******/
ALTER TABLE [dbo].[TiposDeSeguroPorAseguradora]  WITH CHECK ADD  CONSTRAINT [FK_TiposDeSeguroPorAseguradora_Aseguradoras] FOREIGN KEY([IdAseguradora])
REFERENCES [dbo].[Aseguradoras] ([IdAseguradora])
GO
ALTER TABLE [dbo].[TiposDeSeguroPorAseguradora] CHECK CONSTRAINT [FK_TiposDeSeguroPorAseguradora_Aseguradoras]
GO
/****** Object:  ForeignKey [FK_TiposDeSeguroPorAseguradora_TiposSeguro]    Script Date: 06/19/2010 22:12:29 ******/
ALTER TABLE [dbo].[TiposDeSeguroPorAseguradora]  WITH CHECK ADD  CONSTRAINT [FK_TiposDeSeguroPorAseguradora_TiposSeguro] FOREIGN KEY([IdTipoSeguro])
REFERENCES [dbo].[TiposSeguro] ([IdTipoSeguro])
GO
ALTER TABLE [dbo].[TiposDeSeguroPorAseguradora] CHECK CONSTRAINT [FK_TiposDeSeguroPorAseguradora_TiposSeguro]
GO
/****** Object:  ForeignKey [FK_CoberturaPorTipoSeguroMedico_TiposSeguro]    Script Date: 06/19/2010 22:12:29 ******/
ALTER TABLE [dbo].[CoberturaPorTipoSeguroMedico]  WITH CHECK ADD  CONSTRAINT [FK_CoberturaPorTipoSeguroMedico_TiposSeguro] FOREIGN KEY([IdTIpoSeguro])
REFERENCES [dbo].[TiposSeguro] ([IdTipoSeguro])
GO
ALTER TABLE [dbo].[CoberturaPorTipoSeguroMedico] CHECK CONSTRAINT [FK_CoberturaPorTipoSeguroMedico_TiposSeguro]
GO
/****** Object:  ForeignKey [FK_Clientes_Aseguradoras]    Script Date: 06/19/2010 22:12:29 ******/
ALTER TABLE [dbo].[Clientes]  WITH CHECK ADD  CONSTRAINT [FK_Clientes_Aseguradoras] FOREIGN KEY([CodigoAseguradora])
REFERENCES [dbo].[Aseguradoras] ([IdAseguradora])
GO
ALTER TABLE [dbo].[Clientes] CHECK CONSTRAINT [FK_Clientes_Aseguradoras]
GO
/****** Object:  ForeignKey [FK_Clientes_TipoIdentificacion]    Script Date: 06/19/2010 22:12:29 ******/
ALTER TABLE [dbo].[Clientes]  WITH CHECK ADD  CONSTRAINT [FK_Clientes_TipoIdentificacion] FOREIGN KEY([Identificacion])
REFERENCES [dbo].[TipoIdentificacion] ([IdTipoIdentificacion])
GO
ALTER TABLE [dbo].[Clientes] CHECK CONSTRAINT [FK_Clientes_TipoIdentificacion]
GO
/****** Object:  ForeignKey [FK_Clientes_TiposCliente]    Script Date: 06/19/2010 22:12:29 ******/
ALTER TABLE [dbo].[Clientes]  WITH CHECK ADD  CONSTRAINT [FK_Clientes_TiposCliente] FOREIGN KEY([TipoCliente])
REFERENCES [dbo].[TiposCliente] ([IdTipoCliente])
GO
ALTER TABLE [dbo].[Clientes] CHECK CONSTRAINT [FK_Clientes_TiposCliente]
GO
/****** Object:  ForeignKey [FK_Clientes_TiposSeguro]    Script Date: 06/19/2010 22:12:29 ******/
ALTER TABLE [dbo].[Clientes]  WITH CHECK ADD  CONSTRAINT [FK_Clientes_TiposSeguro] FOREIGN KEY([TipoSeguro])
REFERENCES [dbo].[TiposSeguro] ([IdTipoSeguro])
GO
ALTER TABLE [dbo].[Clientes] CHECK CONSTRAINT [FK_Clientes_TiposSeguro]
GO
/****** Object:  ForeignKey [FK_Medicos_EspecialidadesMedicas]    Script Date: 06/19/2010 22:12:29 ******/
ALTER TABLE [dbo].[Medicos]  WITH CHECK ADD  CONSTRAINT [FK_Medicos_EspecialidadesMedicas] FOREIGN KEY([IdEspecialidad])
REFERENCES [dbo].[EspecialidadesMedicas] ([IdEspecialidad])
GO
ALTER TABLE [dbo].[Medicos] CHECK CONSTRAINT [FK_Medicos_EspecialidadesMedicas]
GO
/****** Object:  ForeignKey [FK_ServiciosMedicos_TiposDeServicio]    Script Date: 06/19/2010 22:12:29 ******/
ALTER TABLE [dbo].[ServiciosMedicos]  WITH CHECK ADD  CONSTRAINT [FK_ServiciosMedicos_TiposDeServicio] FOREIGN KEY([TipoDeServicio])
REFERENCES [dbo].[TiposDeServicio] ([IdTipoDeServicio])
GO
ALTER TABLE [dbo].[ServiciosMedicos] CHECK CONSTRAINT [FK_ServiciosMedicos_TiposDeServicio]
GO
/****** Object:  ForeignKey [FK_ServiciosMedicos_Unidades]    Script Date: 06/19/2010 22:12:29 ******/
ALTER TABLE [dbo].[ServiciosMedicos]  WITH CHECK ADD  CONSTRAINT [FK_ServiciosMedicos_Unidades] FOREIGN KEY([TipoUnidad])
REFERENCES [dbo].[Unidades] ([IdUnidades])
GO
ALTER TABLE [dbo].[ServiciosMedicos] CHECK CONSTRAINT [FK_ServiciosMedicos_Unidades]
GO
/****** Object:  ForeignKey [FK_PersonasDeContacto_Clientes]    Script Date: 06/19/2010 22:12:29 ******/
ALTER TABLE [dbo].[PersonasDeContacto]  WITH CHECK ADD  CONSTRAINT [FK_PersonasDeContacto_Clientes] FOREIGN KEY([IdCliente])
REFERENCES [dbo].[Clientes] ([IdCliente])
GO
ALTER TABLE [dbo].[PersonasDeContacto] CHECK CONSTRAINT [FK_PersonasDeContacto_Clientes]
GO
/****** Object:  ForeignKey [FK_PersonasDeContacto_Parentescos]    Script Date: 06/19/2010 22:12:29 ******/
ALTER TABLE [dbo].[PersonasDeContacto]  WITH CHECK ADD  CONSTRAINT [FK_PersonasDeContacto_Parentescos] FOREIGN KEY([Parentesco])
REFERENCES [dbo].[Parentescos] ([IdParentesco])
GO
ALTER TABLE [dbo].[PersonasDeContacto] CHECK CONSTRAINT [FK_PersonasDeContacto_Parentescos]
GO
/****** Object:  ForeignKey [FK_MaterialGastableServiciosMedicos_ServiciosMedicos]    Script Date: 06/19/2010 22:12:29 ******/
ALTER TABLE [dbo].[MaterialGastableServiciosMedicos]  WITH CHECK ADD  CONSTRAINT [FK_MaterialGastableServiciosMedicos_ServiciosMedicos] FOREIGN KEY([IdServicioMedico])
REFERENCES [dbo].[ServiciosMedicos] ([IdServicioMedico])
GO
ALTER TABLE [dbo].[MaterialGastableServiciosMedicos] CHECK CONSTRAINT [FK_MaterialGastableServiciosMedicos_ServiciosMedicos]
GO
/****** Object:  ForeignKey [FK_MaterialGastableServiciosMedicos_TipoInsumo]    Script Date: 06/19/2010 22:12:29 ******/
ALTER TABLE [dbo].[MaterialGastableServiciosMedicos]  WITH CHECK ADD  CONSTRAINT [FK_MaterialGastableServiciosMedicos_TipoInsumo] FOREIGN KEY([IdInsumo])
REFERENCES [dbo].[TipoInsumo] ([IdTipoInsumo])
GO
ALTER TABLE [dbo].[MaterialGastableServiciosMedicos] CHECK CONSTRAINT [FK_MaterialGastableServiciosMedicos_TipoInsumo]
GO
/****** Object:  ForeignKey [FK_Insumos_ClaseInsumo]    Script Date: 06/19/2010 22:12:29 ******/
ALTER TABLE [dbo].[Insumos]  WITH CHECK ADD  CONSTRAINT [FK_Insumos_ClaseInsumo] FOREIGN KEY([ClaseInsumo])
REFERENCES [dbo].[ClaseInsumo] ([IdClaseInsumo])
GO
ALTER TABLE [dbo].[Insumos] CHECK CONSTRAINT [FK_Insumos_ClaseInsumo]
GO
/****** Object:  ForeignKey [FK_Insumos_TipoInsumo]    Script Date: 06/19/2010 22:12:29 ******/
ALTER TABLE [dbo].[Insumos]  WITH CHECK ADD  CONSTRAINT [FK_Insumos_TipoInsumo] FOREIGN KEY([TipoInsumo])
REFERENCES [dbo].[TipoInsumo] ([IdTipoInsumo])
GO
ALTER TABLE [dbo].[Insumos] CHECK CONSTRAINT [FK_Insumos_TipoInsumo]
GO
/****** Object:  ForeignKey [FK_HistorialClinico_Clientes]    Script Date: 06/19/2010 22:12:29 ******/
ALTER TABLE [dbo].[HistorialClinico]  WITH CHECK ADD  CONSTRAINT [FK_HistorialClinico_Clientes] FOREIGN KEY([IdPaciente])
REFERENCES [dbo].[Clientes] ([IdCliente])
GO
ALTER TABLE [dbo].[HistorialClinico] CHECK CONSTRAINT [FK_HistorialClinico_Clientes]
GO
/****** Object:  ForeignKey [FK_ServiciosPorCobertura_CoberturaPorTipoSeguroMedico]    Script Date: 06/19/2010 22:12:29 ******/
ALTER TABLE [dbo].[ServiciosPorCobertura]  WITH CHECK ADD  CONSTRAINT [FK_ServiciosPorCobertura_CoberturaPorTipoSeguroMedico] FOREIGN KEY([IdCovertura])
REFERENCES [dbo].[CoberturaPorTipoSeguroMedico] ([IdCobertura])
GO
ALTER TABLE [dbo].[ServiciosPorCobertura] CHECK CONSTRAINT [FK_ServiciosPorCobertura_CoberturaPorTipoSeguroMedico]
GO
/****** Object:  ForeignKey [FK_ServiciosPorCobertura_ServiciosMedicos]    Script Date: 06/19/2010 22:12:29 ******/
ALTER TABLE [dbo].[ServiciosPorCobertura]  WITH CHECK ADD  CONSTRAINT [FK_ServiciosPorCobertura_ServiciosMedicos] FOREIGN KEY([IdServicio])
REFERENCES [dbo].[ServiciosMedicos] ([IdServicioMedico])
GO
ALTER TABLE [dbo].[ServiciosPorCobertura] CHECK CONSTRAINT [FK_ServiciosPorCobertura_ServiciosMedicos]
GO
/****** Object:  ForeignKey [FK_ServiciosMedicosPorMedicos_Medicos]    Script Date: 06/19/2010 22:12:29 ******/
ALTER TABLE [dbo].[ServiciosMedicosPorMedicos]  WITH CHECK ADD  CONSTRAINT [FK_ServiciosMedicosPorMedicos_Medicos] FOREIGN KEY([IdMedico])
REFERENCES [dbo].[Medicos] ([IdMedico])
GO
ALTER TABLE [dbo].[ServiciosMedicosPorMedicos] CHECK CONSTRAINT [FK_ServiciosMedicosPorMedicos_Medicos]
GO
/****** Object:  ForeignKey [FK_ServiciosMedicosPorMedicos_ServiciosMedicos]    Script Date: 06/19/2010 22:12:29 ******/
ALTER TABLE [dbo].[ServiciosMedicosPorMedicos]  WITH CHECK ADD  CONSTRAINT [FK_ServiciosMedicosPorMedicos_ServiciosMedicos] FOREIGN KEY([IdServicioMedico])
REFERENCES [dbo].[ServiciosMedicos] ([IdServicioMedico])
GO
ALTER TABLE [dbo].[ServiciosMedicosPorMedicos] CHECK CONSTRAINT [FK_ServiciosMedicosPorMedicos_ServiciosMedicos]
GO
/****** Object:  ForeignKey [FK_ConsultaMedica_Clientes]    Script Date: 06/19/2010 22:12:29 ******/
ALTER TABLE [dbo].[ConsultaMedica]  WITH CHECK ADD  CONSTRAINT [FK_ConsultaMedica_Clientes] FOREIGN KEY([IdPaciente])
REFERENCES [dbo].[Clientes] ([IdCliente])
GO
ALTER TABLE [dbo].[ConsultaMedica] CHECK CONSTRAINT [FK_ConsultaMedica_Clientes]
GO
/****** Object:  ForeignKey [FK_ConsultaMedica_EstadoConsulta]    Script Date: 06/19/2010 22:12:29 ******/
ALTER TABLE [dbo].[ConsultaMedica]  WITH CHECK ADD  CONSTRAINT [FK_ConsultaMedica_EstadoConsulta] FOREIGN KEY([Estado])
REFERENCES [dbo].[EstadoConsulta] ([IdEstado])
GO
ALTER TABLE [dbo].[ConsultaMedica] CHECK CONSTRAINT [FK_ConsultaMedica_EstadoConsulta]
GO
/****** Object:  ForeignKey [FK_ConsultaMedica_Medicos]    Script Date: 06/19/2010 22:12:29 ******/
ALTER TABLE [dbo].[ConsultaMedica]  WITH CHECK ADD  CONSTRAINT [FK_ConsultaMedica_Medicos] FOREIGN KEY([IdMedico])
REFERENCES [dbo].[Medicos] ([IdMedico])
GO
ALTER TABLE [dbo].[ConsultaMedica] CHECK CONSTRAINT [FK_ConsultaMedica_Medicos]
GO
/****** Object:  ForeignKey [FK_PacientesPorMedicos_Clientes]    Script Date: 06/19/2010 22:12:29 ******/
ALTER TABLE [dbo].[PacientesPorMedicos]  WITH CHECK ADD  CONSTRAINT [FK_PacientesPorMedicos_Clientes] FOREIGN KEY([IdPaciente])
REFERENCES [dbo].[Clientes] ([IdCliente])
GO
ALTER TABLE [dbo].[PacientesPorMedicos] CHECK CONSTRAINT [FK_PacientesPorMedicos_Clientes]
GO
/****** Object:  ForeignKey [FK_PacientesPorMedicos_Medicos]    Script Date: 06/19/2010 22:12:29 ******/
ALTER TABLE [dbo].[PacientesPorMedicos]  WITH CHECK ADD  CONSTRAINT [FK_PacientesPorMedicos_Medicos] FOREIGN KEY([IdMedico])
REFERENCES [dbo].[Medicos] ([IdMedico])
GO
ALTER TABLE [dbo].[PacientesPorMedicos] CHECK CONSTRAINT [FK_PacientesPorMedicos_Medicos]
GO
/****** Object:  ForeignKey [FK_ViasDeContactoClientes_Clientes]    Script Date: 06/19/2010 22:12:30 ******/
ALTER TABLE [dbo].[ViasDeContactoClientes]  WITH CHECK ADD  CONSTRAINT [FK_ViasDeContactoClientes_Clientes] FOREIGN KEY([IdCliente])
REFERENCES [dbo].[Clientes] ([IdCliente])
GO
ALTER TABLE [dbo].[ViasDeContactoClientes] CHECK CONSTRAINT [FK_ViasDeContactoClientes_Clientes]
GO
/****** Object:  ForeignKey [FK_ViasDeContactoClientes_TiposViasDeContacto]    Script Date: 06/19/2010 22:12:30 ******/
ALTER TABLE [dbo].[ViasDeContactoClientes]  WITH CHECK ADD  CONSTRAINT [FK_ViasDeContactoClientes_TiposViasDeContacto] FOREIGN KEY([TipoVia])
REFERENCES [dbo].[TiposViasDeContacto] ([IdTipoVia])
GO
ALTER TABLE [dbo].[ViasDeContactoClientes] CHECK CONSTRAINT [FK_ViasDeContactoClientes_TiposViasDeContacto]
GO
/****** Object:  ForeignKey [FK_ViasDeContacto_PersonasDeContacto]    Script Date: 06/19/2010 22:12:30 ******/
ALTER TABLE [dbo].[ViasDeContacto]  WITH CHECK ADD  CONSTRAINT [FK_ViasDeContacto_PersonasDeContacto] FOREIGN KEY([IdPersona])
REFERENCES [dbo].[PersonasDeContacto] ([IdContacto])
GO
ALTER TABLE [dbo].[ViasDeContacto] CHECK CONSTRAINT [FK_ViasDeContacto_PersonasDeContacto]
GO
/****** Object:  ForeignKey [FK_ViasDeContacto_TiposViasDeContacto]    Script Date: 06/19/2010 22:12:30 ******/
ALTER TABLE [dbo].[ViasDeContacto]  WITH CHECK ADD  CONSTRAINT [FK_ViasDeContacto_TiposViasDeContacto] FOREIGN KEY([TipoVia])
REFERENCES [dbo].[TiposViasDeContacto] ([IdTipoVia])
GO
ALTER TABLE [dbo].[ViasDeContacto] CHECK CONSTRAINT [FK_ViasDeContacto_TiposViasDeContacto]
GO
/****** Object:  ForeignKey [FK_ServiciosMedicosMedicamentos_Insumos]    Script Date: 06/19/2010 22:12:30 ******/
ALTER TABLE [dbo].[ServiciosMedicosMedicamentos]  WITH CHECK ADD  CONSTRAINT [FK_ServiciosMedicosMedicamentos_Insumos] FOREIGN KEY([IdInsumo])
REFERENCES [dbo].[Insumos] ([IdInsumo])
GO
ALTER TABLE [dbo].[ServiciosMedicosMedicamentos] CHECK CONSTRAINT [FK_ServiciosMedicosMedicamentos_Insumos]
GO
/****** Object:  ForeignKey [FK_ServiciosMedicosMedicamentos_ServiciosMedicos]    Script Date: 06/19/2010 22:12:30 ******/
ALTER TABLE [dbo].[ServiciosMedicosMedicamentos]  WITH CHECK ADD  CONSTRAINT [FK_ServiciosMedicosMedicamentos_ServiciosMedicos] FOREIGN KEY([IdServicioMedico])
REFERENCES [dbo].[ServiciosMedicos] ([IdServicioMedico])
GO
ALTER TABLE [dbo].[ServiciosMedicosMedicamentos] CHECK CONSTRAINT [FK_ServiciosMedicosMedicamentos_ServiciosMedicos]
GO
/****** Object:  ForeignKey [FK_HistorialClinicoDetalle_HistorialClinico]    Script Date: 06/19/2010 22:12:30 ******/
ALTER TABLE [dbo].[HistorialClinicoDetalle]  WITH CHECK ADD  CONSTRAINT [FK_HistorialClinicoDetalle_HistorialClinico] FOREIGN KEY([IdHistorial])
REFERENCES [dbo].[HistorialClinico] ([IdHistorial])
GO
ALTER TABLE [dbo].[HistorialClinicoDetalle] CHECK CONSTRAINT [FK_HistorialClinicoDetalle_HistorialClinico]
GO
/****** Object:  ForeignKey [FK_HistorialClinicoDetalle_Medicos]    Script Date: 06/19/2010 22:12:30 ******/
ALTER TABLE [dbo].[HistorialClinicoDetalle]  WITH CHECK ADD  CONSTRAINT [FK_HistorialClinicoDetalle_Medicos] FOREIGN KEY([IdMedico])
REFERENCES [dbo].[Medicos] ([IdMedico])
GO
ALTER TABLE [dbo].[HistorialClinicoDetalle] CHECK CONSTRAINT [FK_HistorialClinicoDetalle_Medicos]
GO
/****** Object:  ForeignKey [FK_HistorialClinicoDetalle_ServiciosMedicos]    Script Date: 06/19/2010 22:12:30 ******/
ALTER TABLE [dbo].[HistorialClinicoDetalle]  WITH CHECK ADD  CONSTRAINT [FK_HistorialClinicoDetalle_ServiciosMedicos] FOREIGN KEY([IdServicioMedico])
REFERENCES [dbo].[ServiciosMedicos] ([IdServicioMedico])
GO
ALTER TABLE [dbo].[HistorialClinicoDetalle] CHECK CONSTRAINT [FK_HistorialClinicoDetalle_ServiciosMedicos]
GO
/****** Object:  ForeignKey [FK_IndicacionesDeUsoInsumos_IndicacionesDeUso]    Script Date: 06/19/2010 22:12:30 ******/
ALTER TABLE [dbo].[IndicacionesDeUsoInsumos]  WITH CHECK ADD  CONSTRAINT [FK_IndicacionesDeUsoInsumos_IndicacionesDeUso] FOREIGN KEY([IdIndicacionInsumo])
REFERENCES [dbo].[IndicacionesDeUso] ([IdIndicacionesdeUso])
GO
ALTER TABLE [dbo].[IndicacionesDeUsoInsumos] CHECK CONSTRAINT [FK_IndicacionesDeUsoInsumos_IndicacionesDeUso]
GO
/****** Object:  ForeignKey [FK_IndicacionesDeUsoInsumos_Insumos]    Script Date: 06/19/2010 22:12:30 ******/
ALTER TABLE [dbo].[IndicacionesDeUsoInsumos]  WITH CHECK ADD  CONSTRAINT [FK_IndicacionesDeUsoInsumos_Insumos] FOREIGN KEY([IdInsumo])
REFERENCES [dbo].[Insumos] ([IdInsumo])
GO
ALTER TABLE [dbo].[IndicacionesDeUsoInsumos] CHECK CONSTRAINT [FK_IndicacionesDeUsoInsumos_Insumos]
GO
/****** Object:  ForeignKey [FK_ContactosClientes_Clientes]    Script Date: 06/19/2010 22:12:30 ******/
ALTER TABLE [dbo].[ContactosClientes]  WITH CHECK ADD  CONSTRAINT [FK_ContactosClientes_Clientes] FOREIGN KEY([IdCliente])
REFERENCES [dbo].[Clientes] ([IdCliente])
GO
ALTER TABLE [dbo].[ContactosClientes] CHECK CONSTRAINT [FK_ContactosClientes_Clientes]
GO
/****** Object:  ForeignKey [FK_ContactosClientes_ViasDeContacto]    Script Date: 06/19/2010 22:12:30 ******/
ALTER TABLE [dbo].[ContactosClientes]  WITH CHECK ADD  CONSTRAINT [FK_ContactosClientes_ViasDeContacto] FOREIGN KEY([IdViaContacto])
REFERENCES [dbo].[ViasDeContacto] ([IdViaContacto])
GO
ALTER TABLE [dbo].[ContactosClientes] CHECK CONSTRAINT [FK_ContactosClientes_ViasDeContacto]
GO
/****** Object:  ForeignKey [FK_Contactos_PersonasDeContacto]    Script Date: 06/19/2010 22:12:30 ******/
ALTER TABLE [dbo].[Contactos]  WITH CHECK ADD  CONSTRAINT [FK_Contactos_PersonasDeContacto] FOREIGN KEY([IdPersonaContacto])
REFERENCES [dbo].[PersonasDeContacto] ([IdContacto])
GO
ALTER TABLE [dbo].[Contactos] CHECK CONSTRAINT [FK_Contactos_PersonasDeContacto]
GO
/****** Object:  ForeignKey [FK_Contactos_ViasDeContacto]    Script Date: 06/19/2010 22:12:30 ******/
ALTER TABLE [dbo].[Contactos]  WITH CHECK ADD  CONSTRAINT [FK_Contactos_ViasDeContacto] FOREIGN KEY([IdViaContacto])
REFERENCES [dbo].[ViasDeContacto] ([IdViaContacto])
GO
ALTER TABLE [dbo].[Contactos] CHECK CONSTRAINT [FK_Contactos_ViasDeContacto]
GO
